<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="box">
      <strong>strong</strong>
      <span>span</span>
    </div>
    <ul>
      <li>li1</li>
      <li>li2</li>
      <li>li3</li>
      <li>li4</li>
      <li>li5</li>
    </ul>
    <script>
      var box = document.getElementsByClassName("box")[0];
      //1）删除当前节点及子节点
      //box.remove();

      //2）删除子节点
      var span = box.getElementsByTagName("span")[0]; //找box下的span标签
      box.removeChild(span);

      //需求：删除ul中的所有li标签
      var ul = document.getElementsByTagName('ul')[0];
      var lis = ul.getElementsByTagName('li');
      console.log(lis.length);
      for(var i=0; i<lis.length;i++){
        ul.removeChild(lis[i]);
        --i;
        //数组下标动态变化，始终删除下标为0的li标签，直到全部删除完毕
      }
    </script>
  </body>
</html>
